export default {
    data() {
        return {
            IdentityTmplId: ['RUK6uQkEv8DQyJRTK0ny0OIfEvalEUZJ7qjJaSyOcF0'],
            OrderTmplId: ['3Z2eE6czUkAkKpz9dvAuyrAHQudMlhLcSHs3a806vMM'],
            GraphTmplId: ['tUkOIf2_tIzVF_mNHM8ljnHRGsg_WwhGtFz1Fpy9ngA']
        }
    },
    methods: {
        /**
         * 根据角色加载对应消息
         */
        subscribeMessage(tmplIds) {
            return new Promise(async (resolve, reject) => {
                uni.requestSubscribeMessage({
                    tmplIds: tmplIds,
                    success(e) {
                        resolve({
                            code: 1,
                            msg: '订阅成功'
                        })
                    },
                    fail(e) {
                        resolve({
                            code: 3,
                            msg: e.errMsg
                        })
                    }
                })
            })
        },
        subscribeMessageOld() {
            return new Promise(async (resolve, reject) => {
                let ret = await this.$request('common', 'msgTemplates');
                if (ret.code != 1) {
                    resolve({
                        code: 3,
                        msg: ret.msg
                    })
                    return;
                }

                let cacheMessageList = ret.data;
                uni.requestSubscribeMessage({
                    tmplIds: cacheMessageList.map(t => {
                        return t.TemplateId
                    }),
                    success(e) {
                        resolve({
                            code: 1,
                            msg: '订阅成功'
                        })
                    },
                    fail(e) {
                        console.log('subscribeMessage', e)
                        resolve({
                            code: 3,
                            msg: e.errMsg
                        })
                    }
                })
            })
        }
    }
}
